Skip to content

fix(docker): handle sigterm & sigint#31624

Closed
gabemeola wants to merge 1 commit into
anomalyco:devfrom
gabemeola:gabe/docker-init
Closed

fix(docker): handle sigterm & sigint#31624
gabemeola wants to merge 1 commit into
anomalyco:devfrom
gabemeola:gabe/docker-init

Conversation

@gabemeola

@gabemeola gabemeola commented Jun 10, 2026

Copy link
Copy Markdown

Issue for this PR

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Currently running docker run -it ghcr.io/anomalyco/opencode serve never always the process to be gracefully closed with SIGTERM and handles forever. This is because it runs as the ENTRYPOINT on PID 1 with no process handler.

Running with docker flag --init does fix it but this is only for the docker runner and isn't cross platform (e.g. kubernetes).

Instead we bake tini into the image which handles signal forwarding and child reaping.

How did you verify your code works?

~/WEBDEV/tmp/opencode/packages/opencode 11s ❯ docker buildx build --platform linux/arm64 -t opencode-test --load .
[+] Building 0.7s (10/10) FINISHED                                   docker-container:mybuilder
 => [internal] load build definition from Dockerfile                                       0.0s
 => => transferring dockerfile: 870B                                                       0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                           0.3s
 => [internal] load .dockerignore                                                          0.0s
 => => transferring context: 2B                                                            0.0s
 => [base 1/2] FROM docker.io/library/alpine:latest@sha256:a2d49ea686c2adfe3c992e47dc3b5e  0.0s
 => => resolve docker.io/library/alpine:latest@sha256:a2d49ea686c2adfe3c992e47dc3b5e7fa6e  0.0s
 => [internal] load build context                                                          0.0s
 => => transferring context: 195B                                                          0.0s
 => CACHED [base 2/2] RUN apk add libgcc libstdc++ ripgrep tini                            0.0s
 => CACHED [build-arm64 1/1] COPY dist/opencode-linux-arm64-musl/bin/opencode /usr/local/  0.0s
 => CACHED [stage-3 1/1] RUN opencode --version                                            0.0s
 => exporting to docker image format                                                       0.2s
 => => exporting layers                                                                    0.0s
 => => exporting manifest sha256:f68e6670a7e68fc1798eb39e5a89c56396a8d2c65247ec39e47c6f75  0.0s
 => => exporting config sha256:cc45a97f594b9108cb6c660778b629c5e35fc10e3a2e3b0da1e4d2a10e  0.0s
 => => sending tarball                                                                     0.2s
 => importing to docker                                                                    0.0s

View build details: docker-desktop://dashboard/build/mybuilder/mybuilder0/pf4iengevap7kf510kmz97l17
~/WEBDEV/tmp/opencode/packages/opencode ❯ docker run -it opencode-test serve
Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.
opencode server listening on http://127.0.0.1:4096
^C⏎                                                                                             ~/WEBDEV/tmp/opencode/packages/opencode ❯

Screenshots / recordings

nil

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jun 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@gabemeola

gabemeola commented Jun 21, 2026

Copy link
Copy Markdown
Author

Rolled these changes into a new docker image in the meantime since this pr is getting stale.

https://github.com/sprisa/opencode-server

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opencode always fails to start properly in Docker

1 participant